<style>
	#fenlei_box{border: 1px solid #3297ff;position: absolute;width:auto;height:250px;overflow-y: auto; z-index:9999;background:#fff;display:none;}
	#fenlei_box li{list-style: none;color:#3297ff;text-align:center;margin-left:-40px;line-height: 32px;cursor: pointer;padding-left:20px;padding-right:20px;}
</style>
                    <form method="post" enctype="multipart/form-data" target="_blank" id="form-order">
                        <div class="table-responsive">
                            <table class="table table-bordered table-hover">
                                <thead>
                                <tr>
                                    <td style="width: 1px;" class="text-center"><input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', this.checked);"></td>
    
                                    <td class="text-right">
                                        <a href="javascript:sort('user_id');">ID</a>
                                    </td>
                                    <td class="text-left" width="120">
                                        <a href="javascript:sort('username');">会员昵称</a>
                                    </td>
                                    <td class="text-left">
                                        <a href="javascript:sort('username');">姓名</a>
                                    </td>
                                   
									<td class="text-center">
									    <a href="javascript:sort('custom_amount');">消费金额</a>
									</td>

<!--                                    <td class="text-left">
                                        <a href="javascript:sort('level');">会员等级</a>
                                    </td> -->
<!--                                    <td class="text-left">
                                        <a href="javascript:sort('total_amount');">累计消费</a>
                                    </td> -->
                                    
                                    <td class="text-left">
                                        <a href="javascript:void(0);">公司/店铺</a>
                                    </td>
<!--                                    <td class="text-left">
                                        <a href="javascript:void(0);">二级下线数</a>
                                    </td> -->
<!--                                    <td class="text-left">
                                        <a href="javascript:void(0);">三级下线数</a>
                                    </td>    -->                                
                                    <td class="text-left">
                                        <a href="javascript:sort('mobile');">手机号码</a>
                                    </td>
									<td class="text-left">
									    <a href="javascript:sort('fenbu_id');">所属区域</a>
									</td>
									<td class="text-left">
                                        <a href="javascript:sort('mobile');">地址</a>
                                    </td>
								 	<td class="text-left">
									   <a href="javascript:sort('xiaxian');" style="width:70px;display:block;">推荐客户</a>
									</td>   
                                    <td class="text-left">
                                        <a href="javascript:sort('reg_time');">注册日期</a>
                                    </td>
                                    <td class="text-center" width="60">操作</td>
                                </tr>
                                </thead>
                                <tbody>
                                <volist name="userList" id="list">
                                    <tr>
                                        <td class="text-center">
                                            <input type="checkbox" name="selected[]" value="{$list['user_id']}">
                                            <input type="hidden" name="shipping_code[]" value="flat.flat">
                                        </td>
                                        <td class="text-right">{$list.user_id}</td>
                                        <td class="text-left">{$list.nick_name}</td>
										<td class="text-left">{$list.nickname}</td>
										<td class="text-left">{$list.custom_amount}</td>
										<td class="text-left">{$list.company}</td>
										<td class="text-left">{$list.mobile}</td>
										<!--区域设置-->
										<td class="text-left">
										<?php
										if(session('fenbu_id')==0){
										?>
										
											<?php
												foreach($fenbu_list as $v){
													if($list['fenbu_id']==$v['fenbu_id']){
														echo $v['fenbu_name'];
													}else{
														echo $v['fenbu_name'];
													}
												}
											?>
										<?php
										}else{
											foreach($fenbu_list as $v){
												if($list['fenbu_id']==$v['fenbu_id']){
													echo $v['fenbu_name'];
												}
											}
										}
										?>
										</td>
										<td class="text-left">
										{$list.company_address}
										</td>
										<td class="text-left" style="color: red;cursor: pointer;" title="点击查看"> {$list.xiaxian}  
										<i class="fa fa-eye" style="color: green;" id="chakan" rel="{$list.user_id}">查看</i> </td>  
                                        <td class="text-left">{$list.reg_time|date='Y-m-d H:i',###}</td>
										<td class="text-right">
											<a href="{:U('Admin/crm/delete',array('id'=>$list['user_id']))}" id="button-delete6" data-toggle="tooltip" title="删除" class="btn btn-danger" data-original-title="删除" style="padding-right: 14px;padding-left: 14px;"
                                             ><i class="fa fa-trash-o"></i></a>
                                        </td>
                                    </tr>
                                </volist>
                                </tbody>
                            </table>
                        </div>
                    </form>
                    <div class="row">
                        <div class="col-sm-3 text-left">
                        </div>
                        <div class="col-sm-6 text-right">{$page}</div>
                    </div>
<script>
	$(".table-responsive #chakan").click(function(){
		var myrel=$(this).attr('rel');
		var myrul='/index.php/Admin/crm/xiaxians/user_id/'+myrel;//+myrel;
			layer.open({
			  type: 2,
			  title:'下线明细',
			  shadeClose: true, //点击遮罩关闭
			  skin: 'layui-layer-rim', //加上边框
			  area: ['920px', '620px'], //宽高
			  content: myrul
		})
	});
	
	 $("body").on("click", function() {
	 	$('body #fenlei_box').hide(100);
	 });
	
	function quyu_sousuo(obj)
	     {
	         var value = obj.val();
	         $.ajax({
	             url:"/Admin/User/quyu_sousuo?key="+value,
	             success: function(data){
					 if(data!=''){
						obj.parent().find('#fenlei_box').show(100);
						obj.parent().find('#fenlei_box').html(data);
					 }else{
						obj.parent().find('#fenlei_box').hide(100);
					 }
	             }
	         });
	     }

	 $("body").on("click", function() {
	 	$('body #fenlei_box').hide(100);
	 });
	
	$("body #fenlei_box").on("click","li", function() {
			var ids=$(this).attr('rev');
			var id=$(this).parent().attr('rel');
			ids=ids.split(',');
			var parent_id=ids[0];

		$.post("/Admin/User/quyu_edit",
		  {
		    id:id,
		    parent_id:parent_id
		  },
		  function(data,status){
			  layer.msg('推荐人设置成功！',{icon:6,time:1000});
		    $('body #fenlei_box').hide(100);
		  });
			
	});
// 修改指定表的指定字段值
function changeTableVal_shadow(table,id_name,id_value,field,obj)
{
		var src = "";
		 if($(obj).attr('src').indexOf("cancel.png") > 0 )
		 {          
				src = '/Public/images/yes.png';
				var value = 0;
				
		 }else{
				src = '/Public/images/cancel.png';
				var value = 1;
		 }
		$.ajax({
				url:"/index.php?m=Admin&c=Index&a=changeTableVal&table="+table+"&id_name="+id_name+"&id_value="+id_value+"&field="+field+'&value='+value,			
				success: function(data){
					$(obj).attr('src',src);
				}
		});		
}

    // 修改指定表的指定字段值  by众创织梦-邵
    function changeTableVal_sofwu(table,id_name,id_value,field,obj)
    {
        var src = "";
        if($(obj).attr('src').indexOf("cancel.png") > 0 )
        {
            src = '/Public/images/yes.png';
            var value = 1;

        }else{
            src = '/Public/images/cancel.png';
            var value = 0;
        }
        $.ajax({
            url:"/index.php?m=Admin&c=Index&a=changeTableVal&table="+table+"&id_name="+id_name+"&id_value="+id_value+"&field="+field+'&value='+value,
            success: function(data){
                $(obj).attr('src',src);
            }
        });
    }
    $(".pagination  a").click(function(){
        var page = $(this).data('p');
        ajax_get_table('search-form2',page);
    });

    //批量删除
    function datadel() {
        //获取选中的文章
        layer.confirm('确认要删除吗？',function(index){
            var inputs = $('input:checked');
            var ids ="";
            $.each(inputs,function (k,v) {
                if (v.value != ""){
                    ids += "," + v.value;
                }
            });
            $.ajax({
                type: 'GET',
                data:{
                    id:ids
                },
                url:"{:U('Admin/user/batch_delete')}",
                dataType: 'json',
                success: function(data){
                    if (data.status>0){
                        layer.msg(data.msg,{icon:1,time:1000});
                        document.location.reload();
                    }else{
                        layer.msg(data.msg,{icon:6,time:1000});
                    }

                }
            });
        } ,function(index){
            layer.close(index);
            return false;// 取消
        })
    }

</script>